<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
    <ui:composition>
        <h:form id="formNavLeftId">
            <p:poll interval="60" update="topReportId" />  
            <p:panel header="User is {#{navigatorBean.profile.opduser.loginname}}" 
                     style="text-align: left; font-size: smaller; font-weight: lighter; margin: 0px">
                <ui:repeat value="#{navigatorBean.profile}" var="p">
                    <h:outputText value="ชื่อ : #{p.opduser.name}"/><p:separator/>
                    <h:outputText value="ตำแหน่ง : #{p.opduser.entryposition}"/><p:separator/>
                    <h:outputText value="ระดับการเข้าถึง : #{p.role.roleNameTH}"/><p:separator/>
                    <h:outputText value="เข้าใช้งานล่าสุด : "/>
                    <h:outputText value="#{p.profileLastAccessDatetime}"><p:separator/>
                        <f:convertDateTime type="date" locale="th_TH" pattern="dd/MM/yyyy HH:mm"/>
                    </h:outputText>
                </ui:repeat>
            </p:panel>

            <p:spacer height="5px"/>

            <p:panel header="Navigator" style="text-align: left; font-size: smaller; margin: 0px">
                <h:panelGrid columns="1" style="width: 100%; font-size: small">
                    <p:panelMenu style="font-size: small; text-align: left" rendered="#{privilegeBean.backend()}">
                        <p:submenu label="Administrator Tools">
                            <p:menuitem value="Setting Profile" icon="ui-icon-gear" 
                                        onclick="javascript:location.href='settingProfile.xhtml'"/>
                        </p:submenu>
                    </p:panelMenu>
                    <p:commandButton value="บันทึกรายงานความเสี่ยง" icon="ui-icon-circle-arrow-e"
                                     action="#{riskAddBean.destroy}" ajax="false"
                                     style="vertical-align: bottom; width: 100%; text-align: left"/>
                    <p:commandButton value="ดูบัญชีความเสี่ยง" icon="ui-icon-circle-arrow-e" ajax="false"
                                     style="vertical-align: bottom; width: 100%; text-align: left" 
                                     action="#{riskListBean.reset}"/>
                    <p:commandButton value="ดูสรุปรายการความเสี่ยง" rendered="#{privilegeBean.viewReport()}"
                                     action="#{riskSummaryBean.reset()}" icon="ui-icon-circle-arrow-e"
                                     style="vertical-align: bottom; width: 100%; text-align: left" ajax="false"/>
                    <p:commandButton value="ออกจากระบบ" icon="ui-icon-circle-arrow-e" ajax="false"
                                     onclick="javascript:location.href='#{request.contextPath}/j_spring_security_logout'"
                                     style="vertical-align: bottom; width: 100%; text-align: left"/>
                </h:panelGrid>
            </p:panel>

            <p:spacer height="5px"/>

            <p:dataTable id="topReportId" var="tops" rowIndexVar="no" styleClass="borderGrid"
                         scrollable="true" scrollHeight="150"
                         style="width: 100%; font-size: small; text-align: left; margin: 0px"
                         value="#{navigatorBean.topReportList}">
                <f:facet name="header">Risk Top 20 Report</f:facet>
                <p:column style="text-align: left; width: 80%">
                    <h:outputText value="#{no+1}.#{tops.fullname}" />
                </p:column>
                <p:column style="text-align: center; width: 20%">
                    <h:outputText value="#{tops.point}" />
                </p:column>
            </p:dataTable>
        </h:form>
    </ui:composition>
</html>